package com.weather;

import java.io.Serializable;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Activitate in care se afiseaza prognoza meteo pentru o zi
 *
 */
public class ExtendedForecast extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.daily_forecast);
		
		ForecastInfo info = (ForecastInfo) getIntent().getSerializableExtra("info"); 
		
		TextView day = (TextView) findViewById(R.id.day);
		day.setText(info.getDay()+" in "+getIntent().getStringExtra("city")+":");
		ImageView image = (ImageView) findViewById(R.id.icon);
   	  	image.setImageResource(info.getIcon());
   	  	TextView cond = (TextView) findViewById(R.id.cond);
		cond.setText(info.getCond()+", "+info.getTemp()+"\u2103");
		
	}
}

/**
 * Prognoza meteo pentru o zi
 *
 */
class ForecastInfo implements Serializable{
	
	private static final long serialVersionUID = 1L;
	private String day, cond;
	private int icon, temp;
	
	public ForecastInfo (String day, String temp, int icon, String cond) {
		this.day = day;
		this.icon = icon;
		this.cond = cond;
		this.temp = (Integer.parseInt(temp) - 32) * 5 / 9;
	}

	public String getDay() {
		return day;
	}

	public int getIcon() {
		return icon;
	}

	public int getTemp() {
		return temp;
	}

	public String getCond() {
		return cond;
	}
}